﻿using System.Reactive;
using ReactiveUI;

namespace AppStandard.ViewModels
{
    // 所有ViewModel继承ViewModelBase
    public class MainViewModel : ViewModelBase, IScreen
    {
        // ReactiveUI 路由接口实现
        public RoutingState Router { get; } = new RoutingState();

        // 导航命令
        public ReactiveCommand<Unit, IRoutableViewModel> GoHome { get; }
        public ReactiveCommand<Unit, IRoutableViewModel> GoSettings { get; }

        public MainViewModel()
        {
            // 使用HostScreen的Router进行导航
            GoHome = ReactiveCommand.CreateFromObservable(
                () => this.Router.Navigate.Execute(new HomeViewModel(this))
            );
            GoSettings = ReactiveCommand.CreateFromObservable(
                () => this.Router.Navigate.Execute(new SettingsViewModel(this))
            );

            // 确保初始页面加载
            this.Router.Navigate.Execute(new HomeViewModel(this));
        }
    }
}
